<?php

class Application_Model_Mailer {

    private $_mail;

    function __construct($subject = "", $body = "", $email = "") {
        $mailConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', 'mail');
        $this->_mail = new Zend_Mail('utf-8');
        $this->_mail->addTo($email);
        $this->_mail->setFrom($mailConfig->mail->from->address, $mailConfig->mail->from->name);
        $this->_mail->setSubject($subject);
        $this->_mail->setBodyHtml(nl2br($body));
    }

    public function addTo($email = "") {
        $this->_mail->addTo($email);
    }

    public function setSubject($subject = "") {
        $this->_mail->setSubject($subject);
    }

    public function setBody($body = "") {
        $this->_mail->setBodyHtml(nl2br($body));
    }

    public function send() {
        $this->_mail->send(new Zend_Mail_Transport_Smtp('smtp.gmail.com', Zend_Registry::get('Mail_Config')));
    }

}

